let permIdFilter = (function (){
  let resultArr = [];
  let getPermId = function(obj){
    if(undefined == obj || null == obj || !obj instanceof Object){
      return;
    }
    if(obj.checked){
      resultArr.push(obj.id);
    }

    if(null != obj.children && obj.children.length > 0 && obj.children instanceof Array){
      for(let child of obj.children){
        getPermId(child);
      }
    }
  }

  return {
    filter : function(arr){
      if(!arr instanceof Array){
        return false;
      }
      resultArr = [];
      for(let rootMenu of arr){
        getPermId(rootMenu);
      }
      return resultArr;
    }
  }
})();

export default permIdFilter
